package main

import "fmt"

func show(a interface{}) {
	fmt.Printf("type:%T value:%v\n", a, a)
}
func main() {
	var x interface{}
	s := "pprof.cn"
	x = s
	fmt.Printf("type:%T value:%v\n", x, x)
	i := 100
	x = i
	fmt.Printf("type:%T value:%v\n", x, x)
	b := true
	x = b
	fmt.Printf("type:%T value:%v\n", x, x)

	if v, ok := x.(string); ok {
		fmt.Printf("type:%T value:%v\n", v, x)
	} else {
		fmt.Println("invalid type")
	}
	show([]int{1, 2, 3})

	var studentInfo = make(map[string]interface{})
	studentInfo["name"] = "ss"
	studentInfo["age"] = 10
	studentInfo["married"] = false
	fmt.Println(studentInfo)
	justifyType(studentInfo)

}

func justifyType(x interface{}) {
	switch v := x.(type) {
	case string:
		fmt.Printf("type:%T value:%v\n", v, v)
	case int:
		fmt.Printf("x is a int is %v\n", v)
	case bool:
		fmt.Printf("x is a bool is %v\n", v)
	case map[string]interface{}:
		fmt.Printf("interface type is map: value is %v\n", v)
	default:
		fmt.Println("unsupport type！")
	}
}
